import { createRouter, createWebHistory } from 'vue-router'
// 引入页面组件
import HomeView from '../views/home/IndexView.vue'
import BaobaoView from '../views/baobao/IndexView.vue'
import OrderView from '../views/order/IndexView.vue'
import UserView from '../views/user/IndexView.vue'
import RegisterView from "../views/register/IndexView.vue"
import LoginView from "../views/login/IndexView.vue"
import IndexView from '../views/index.vue'
import ShopView from "../views/shop/IndexView.vue"
// 构建路由规则
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      //路由重定向
      path: '/',
      redirect:'/index'
    },
    {
      //一级路由
      path: '/index',
      name: 'home',
      component: IndexView,
      children:[
        {
          //二级路由
          path: "/index/home",
          name: "home",
          component: HomeView
        },
        {
          path: "/index/baobao",
          name: "baobao",
          component:BaobaoView,
          children: [
            {
              path: '/tuan/baotuan/qianggou',
              name: 'qianggou',
              meta: { title:'抢购' },
              component: () => import('../views/baobao/baoTuan2L/QiangGou.vue'),
            },
            {
              path: '/tuan/baotuan/shangxin',
              name: 'shangxin',
              meta: { title:'上新' },
              component: () => import('../views/baobao/baoTuan2L/ShangXin.vue'),
            },
          ]
        },
        {
          path: "/index/order",
          name: "order",
          component: OrderView
        },
        {
          path: "/index/user",
          name: "user",
          component: UserView
        },
        {
          //路由重定向
          path: '/index',
          redirect:'/index/home'
        },
      ]
    },
    {//注册
      path:"/register",
      name: "register",
      component: RegisterView
    },
    {//登录
      path:"/login",
      name: "login",
      component: LoginView
    },
    {//店铺
       path:'/shop',
       name: "shop",
       component: ShopView
    }
  ]
})

export default router
